//箭头函数和this

const person = {
  name: "tom",
  //   sayHi: function () {
  //     console.log(`hi, my name is ${this.name}`);
  //   },
  sayHi: () => {
    console.log(`hi, my name is ${this.name}`);
  },
  //   sayHiAsync: function () {
  //     const _this = this;
  //     setTimeout(function () {
  //       console.log(_this.name);
  //     }, 1000);
  //   },
  sayHiAsync: function () {
    setTimeout(() => {
      console.log(this.name);
    }, 1000);
  },
};
person.sayHi();
person.sayHiAsync();
